import React from 'react'
import {Switch, Input, message} from 'antd'
import SetButton from '../SetBtton'
import {inject, observer} from 'mobx-react'

const HOCSetPay = WarpComponent => {
    @inject('setStoreInfo')
    @observer
    class ElementComponent extends React.Component {
        state = {
            pagination:{
                defaultCurrent:1,
                defaultPageSize:5,
                hideOnSinglePage:true
            },
            columns: [
                {
                    title: '支付方式名称',
                    dataIndex: 'pmsNfpm',
                    align:'center'
                },
                {
                    title: '启用',
                    dataIndex: 'pmsEmpstatus',
                    align:'center',
                    render: (pmsEmpstatus) => <Switch defaultChecked={pmsEmpstatus} />
                },
                {
                    title: '排序',
                    dataIndex: 'pmsPmr',
                    align:'center'
                },
                {
                    title: '操作',
                    align:'center',
                    render: () => (
                        <div>
                            <SetButton txt='修改'></SetButton>
                        </div>
                    )
                },
            ],
            data:[]
        }
        componentDidMount(){
            this.getInitData()
        }
        getInitData=()=>{
            let {getPaySet} = this.props.setStoreInfo
            getPaySet().then(data=>{
                if (data.data.code === 200) {
                    let allData = data.data.data
                    let endData = allData.map(item=>{
                        item.key = item.pmsId
                        return item
                    })
                    let obj = this.state
                    obj.data = endData
                    this.setState(obj)
                }else{
                    message.error('查询数据失败')
                }
            })
        }
        render() {
            return (
                <div>
                    <WarpComponent {...this.state}></WarpComponent>
                </div>
            );
        }
    }
    return ElementComponent
}

export default HOCSetPay